#include<SDL.h>
void jeu(SDL_Surface *screen)
{
    SDL_Event event;
    SDL_Rect dstrect;    // initialize SDL video
    int done=0;

    // load an image
    SDL_Surface* bmp = SDL_LoadBMP("img/image.bmp");
    if (!bmp)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());

    }
    SDL_Surface *image = SDL_LoadBMP("img/mario.bmp");
    if (image == NULL)
    {
        printf("Unable to load bitmap: %s\n", SDL_GetError());

    }
    // centre the bitmap on screen

    dstrect.x = 80;
    dstrect.y =  550;

    // program main loop

    SDL_EnableKeyRepeat(100,10);
    SDL_SetColorKey(image,SDL_SRCCOLORKEY,SDL_MapRGB(image->format,255,255,255));
    while (!done)
    {
        // message processing loop

        while (SDL_PollEvent(&event))
        {
            // check for messages
            switch (event.type)
            {
                // exit if the window is closed
            case SDL_QUIT:
                done = 1;
                break;
                // check for keypresses
            case SDL_KEYDOWN:
            {
                // exit if ESCAPE is pressed
                switch (event.key.keysym.sym)
                {
                case  SDLK_ESCAPE:
                    done = 1;
                    break;
                case SDLK_SPACE:
                    dstrect.y=dstrect.y-310;
                    break;
                case SDLK_RIGHT:
                    dstrect.x++;
                    break;
                case SDLK_LEFT:
                    dstrect.x--;
                    break;
                }
                case SDL_KEYUP:
                {
                    switch (event.key.keysym.sym)
                    case SDLK_SPACE:
                    dstrect.y=dstrect.y+155;
                    break;
                }
            }
        }
        break; // end switch
    } // end of message processing
    // DRAWING STARTS HERE
    // clear screen
    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
    // draw bitmap
    SDL_BlitSurface(bmp, NULL, screen, NULL);
    SDL_BlitSurface(image, NULL, screen, &dstrect);
    // DRAWING ENDS HERE
    // finally, update the screen
    SDL_Flip(screen);
    // end main loop

    // all is well


}
// free loaded bitmap
SDL_FreeSurface(bmp);
SDL_FreeSurface(image);

}



